package dang.bean;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.springframework.beans.factory.FactoryBean;
Session在实现类中无法实现注入，因为DaoFactory在使用get方法时，new了一个实现类
public class SessionBean implements FactoryBean {
	
	private static SessionFactory sf;
	
	static{
		Configuration config = new Configuration();
		config.configure();					
		sf = config.buildSessionFactory();
	}
	
	@Override
	public Object getObject() throws Exception {
		return sf.getCurrentSession();
	}

	@Override
	public Class getObjectType() {
		return Session.class;
	}

	@Override
	public boolean isSingleton() {
		return false;
	}

}
